public class Opdracht3_2 {

  public Opdracht3_2(){
    System.out.println("Opdracht 3.1");
    double lol = 0;
    double deA = Main.vraagDouble("A (double)");
    double deB = Main.vraagDouble("B (double)");
    double deC = Main.vraagDouble("C (double)");
    abcPrint(deA,deB,deC);
  }

  public static void abcPrint(double a, double b, double c){
    //Dingen laten zien
    if (a==0){
      System.out.println("Dit is geen 2e graadsvergelijking !");
      return;
    }
    double ans1 = abc(a,b,c,true);
    double ans2 = abc(a,b,c,false);
    if (ans1 == Double.NaN && ans2 == Double.NaN){
      System.out.println("Geen Antwoorden");
      return;
    }
    if (ans1 == Double.NaN || ans2 == Double.NaN){
      System.out.println("1 Antwoord");
      //Nu nog checke welke
      if (ans1 != Double.NaN){
        System.out.println("ans1 = " + ans1);
      } else {
        System.out.println("ans2 = " + ans2);
      }
      return;
    }
    //2 antwoorden
    System.out.println("2 Antwoorden");
    System.out.println("ans1 =" + ans1);
    System.out.println("ans2 =" + ans2);
  }


  public static double abc(double a, double b, double c, boolean plus) {
    //ax²+bx+c=0
    double ans = 0;
    //Plus of Min
    if (plus) {
      ans = (-b + Math.pow(Math.pow(b, 2) - (4 * a * c),0.5)) / (2 * a);
    } else {
      ans = (-b - Math.pow(Math.pow(b, 2) - (4 * a * c),0.5)) / (2 * a);
    }
    return ans;
  }

  public static void main(String[] args){
    new Opdracht3_2();
  }
}
